<?php
$server = "localhost";
$username = "root";
$pwd = "root";
$db = "tawuz";

$con = mysqli_connect($server,$username,$pwd,$db);

$uname = $_POST['uname'];
$uage = $_POST['uage'];
$uads = $_POST['uads'];
$id = $_POST['id'];


if($con){
    if($id==0){
        $sql = "insert into student(uname,uage,uads) values('$uname','$uage','$uads')";
    }else{
        $sql = "update student set uname='$uname',uage='$uage',uads='$uads' where id = $id";
    }
    $run = mysqli_query($con,$sql);
    if($run){
        echo "数据表数据添加或者更新成功！";
    }else{
        echo "已连接数据库，但未能添加或者更新数据！请稍后再试试！".mysqli_error($con);
    }
    mysqli_close($con);
}else{
    echo "未连接数据库，错误内容：".mysqli_connect_error();
}

